<ui:component xmlns:ui="http://java.sun.com/jsf/facelets"
              xmlns:h="http://java.sun.com/jsf/html"
              xmlns:f="http://java.sun.com/jsf/core"
              xmlns:c="http://java.sun.com/jstl/core"
              xmlns:rich="http://richfaces.org/rich"
              xmlns:a4j="http://richfaces.org/a4j"
              xmlns:msn="http://www.contact.messanger.com/contacts/msn/ui"
              xmlns:fn="http://java.sun.com/jsp/jstl/functions"
              xmlns:core="http://www.contact.core.com/contacts/core/ui"
        >
    <a4j:outputPanel layout="none">
        <a4j:form id="form_friendsRoomsList">
            <rich:panel  style="border:0;display:#{empty chatSessionBean.friendsRooms ? 'none' : 'block'};">
                <f:facet name="header">
                    <h:outputText value="#{resources.friendschatFriendsLabel}"/>
                </f:facet>

                <h:panelGrid id="friendsRooms" columns="1" width="100%" rendered="#{friendsSessionBean.status}">
                    <c:forEach items="#{chatSessionBean.friendsRooms}" var="friend" varStatus="stat">
                        <c:if test="#{(not empty friend.friendRooms) and friend.activeFriend.onlineStatus and friend.activeFriend.online and friendsSessionBean.active}">

                            <h:panelGroup id="friend_#{stat.index}" layout="block" style="cursor:pointer;">
                                <core:pictureForViewWithName pictureKey="photoprofile_#{friend.activeFriend.info.id}"
                                                     style="width:30px;height:30px"
                                                     columns="2"
                                                     fullName="#{friend.activeFriend.info.firstName} #{friend.activeFriend.info.lastName}"
                                                     informationId="#{friend.activeFriend.info.id}"/>
                                <rich:contextMenu attached="true" submitMode="ajax" event="onmouseover">
                                    <c:forEach items="#{friend.friendRooms}" var="room">
                                        <rich:menuItem value="#{room.chatTopic}"
                                                       reRender="chatTabs, chatRoomsList"
                                                       action="#{chatRequestBean.openRoom}"
                                                       ajaxSingle="true"
                                                       oncomplete="if ( #{room.chatProtected} ) Richfaces.showModalPanel('protectedRoomModalPanel'); else selectedTab = 'room_#{chatRoom.uniqueKey}';"
                                                >
                                            <a4j:actionparam name="key" assignTo="#{chatRequestBean.roomKey}"
                                                             value="#{room.uniqueKey}"/>
                                        </rich:menuItem>
                                    </c:forEach>
                                </rich:contextMenu>
                            </h:panelGroup>
                        </c:if>
                    </c:forEach>
                </h:panelGrid>

            </rich:panel>
        </a4j:form>
    </a4j:outputPanel>
</ui:component>